<template>
  <div>
    <h1 align="center">新增房价计划</h1>
    <table class="table table-bordered">
      <tr>
        <td align="center">适用房型</td>
        <td>
          <select v-model="state.xid">
            <option value="">全部</option>
            <option  :value="item.xid" v-for="item in listkku">{{item.x_name}}</option>
          </select>
        </td>
      </tr>
      <tr>
        <td align="center">产品名称</td>
        <td>
          <input type="text" v-model="state.p_name" />
        </td>
      </tr>
      <tr>
        <td align="center">标准价格</td>
        <td>
          <input type="text" v-model="state.p_price" />
        </td>
      </tr>
      <tr>
        <td align="center">收款方式</td>
        <td><input type="radio" />预订付费 <input type="radio" />到店付费</td>
      </tr>
      <tr>
        <td align="center">常驻优惠</td>
        <td>
          <input type="checkbox" />可用优惠券抵扣
          <input type="checkbox" />可使用现金券抵扣
        </td>
      </tr>
      <tr>
        <td align="center">会员差价</td>
        <td>
          <input type="radio" />不设置 <input type="radio" />按折扣
          <input type="radio" />按不同价格
        </td>
      </tr>
      <tr>
        <td align="center">早餐份数</td>
        <td>
          <input type="text" v-model="state.p_number" />
        </td>
      </tr>
      <tr>
        <td align="center">房间数量</td>
        <td>
          <input type="text" v-model="state.p_num" />
        </td>
      </tr>
      <tr>
        <td align="center">销售策略</td>
        <td>
          <input type="radio" />无 <input type="radio" />早定优惠
          <input type="radio" />限定优惠 <input type="radio" />今夜甩卖
        </td>
      </tr>
      <tr>
        <td align="center" colspan="2">
          <input type="button" value="确定" @click="ok" />
        </td>
      </tr>
    </table>
  </div>
</template>

<script setup lang="ts">
import { reactive, toRefs, onMounted } from 'vue';
import axios from 'axios';
import { useRouter, useRoute } from 'vue-router';
const router = useRouter();
const route = useRoute();
let data: any = reactive({
  state: {
    p_name: '',
    p_price: 0,
    p_number: 0,
    p_num: 0,
    xid: 0
  },
  listkku:[]
});
let { state,listkku } = toRefs(data);
onMounted(()=>{
  getfangxing();
})
//获取房型
const getfangxing=()=>{
    axios({
      url:'/api/Member/x_price',
      method:'get'
    })
    .then(res=>{
      console.log(res);
      listkku.value=res.data.data
    })
    .catch(err=>{
      console.log(err)
    })
}


//房价确认
const ok = () => {
  let obj = {
    p_name: state.value.p_name,
    p_price: state.value.p_price,
    p_number: state.value.p_number,
    p_num: state.value.p_num,
    xid: state.value.xid
  };
  axios({
    url: '/api/Member/Fprice',
    method: 'post',
    data: obj
  })
    .then((res) => {
      console.log(res);
      if (res.data.data == 1) {
        alert('新增成功');
        router.push('/pshow');
      } else {
        alert('新增失败');
        return;
      }
    })
    .catch((err) => {
      console.log(err);
    });
};
</script>

<style scoped></style>
